<template>
	<view>
		<!-- 总评价统计 -->
		<total-pj 
			:pjScore="pjScore"
			:pjTotalNum="pjTotalNum"
			:pjCNum="pjCNum"
			:pjANum="pjANum"
			:pjBNum="pjBNum"
			@backPage="backPage"
		></total-pj>
		<!-- 评价list -->
		<block v-if="isHasDataFlag">
			<scroll-view scroll-y class="scrollComment" @scrolltolower="scrolltolower">
				<pj-list :pjList="pjList" :loading="loading"></pj-list>
			</scroll-view>
		</block>
		<block v-else-if="isHasDataFlag == false">
			<no-data></no-data>
		</block>
	</view>
</template>

<script>
	import TotalPj from './components/TotalPj'
	import PjList from './components/PjList'
	import { getZxsPjList } from '@/api/xlzx/index'
	export default {
		components:{
			TotalPj,
			PjList
		},
		data(){
			return{
				zxsUserId:'',
				nowPage:1,
				loading:false,
				pjScore : 0,
				pjTotalNum : 0,
				pjCNum : 0,
				pjANum : 0,
				pjBNum : 0,
				pjList:[],
				isHasDataFlag:null
			}
		},
		onLoad(options){
			this.zxsUserId = options.zxsUserId;
			this.loadZxsPjList();
		},
		methods:{
			scrolltolower(){
				if( !this.loading ){
					this.loadZxsPjList();
				}
			},
			loadZxsPjList(){
				let { nowPage,pjList } = this;
				this.loading = true;
				var field = { sUserId:this.zxsUserId,page:this.nowPage,limit:this.limit };
				getZxsPjList(field).then(res=>{
					let tmpRes = res.data.datas[0];
					if(this.nowPage == 1){
						this.pjScore = tmpRes.pjScore;
						this.pjTotalNum = tmpRes.pjTotalNum;
						this.pjCNum = tmpRes.pjCNum;
						this.pjANum = tmpRes.pjANum;
						this.pjBNum = tmpRes.pjBNum;
						if(tmpRes.pjList.length == 0){
							this.loading = false;
							this.isHasDataFlag=false;
						}
					}
					if(tmpRes.pjList.length > 0){
						nowPage += 1;
						pjList.push( ...tmpRes.pjList );
						this.pjList = pjList;
						this.nowPage = nowPage;
						this.loading = false;
						this.isHasDataFlag = true;
					}else{
						if(this.nowPage > 1){
							this.loading = false;
						}
					}
				}).catch(err=>{
					console.log(err)
				});
			},
			backPage(){
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>
<style lang="scss">
	page{
		background: $pss-bg-primary;
	}
</style>
<style lang='scss' scoped>
	.scrollComment{
		position: absolute;
		left: 0;
		top: 280rpx;
		bottom: 0;
		right: 0;
	}
</style>